<script type="text/javascript">document.title="<?=$page_title?> - <?if($access['yd']){?>云顶旅游<?} else {?><?=$GLOBALS['web_title']?>"<?}?>;</script>
<link rel="stylesheet" type="text/css" href="css/c_common.css">
<link rel="stylesheet" type="text/css" href="css/prodlist.css">
<link rel="stylesheet" type="text/css" href="css/easydialog.css"/>
<link rel="stylesheet" type="text/css" href="css/page.css">
<link rel="stylesheet" type="text/css" href="css/my_buttons.css">
<style>
.export {display: inline-block;margin-top: 10px;float: right;height: 32px;cursor: pointer;font-size: 0;
border: 0 none;text-indent: -9999px;background: url(http://www.12301.cc/images/order/ysearchBtn.gif) no-repeat;}
.exportbtn {width: 84px;background-position: right top;}
.up_file {float: right;margin-top: -50px;margin-right:10px;}
.content .tabHead{ padding-left:15px; overflow:hidden; border-bottom:2px solid #019be1}
.content .tabHead li{ float:left; height:36px; line-height:36px; padding:0 25px; cursor:pointer; border-top-left-radius:2px; border-top-right-radius:2px;}
.content .tabHead li.active{ background:#019be1; color:#fff}
.w75{width:80px;height:24px;line-height:24px;border: 1px solid #ccc;}
table.search_tbl tr {
margin-top: 10px;
}
</style>

<div class="clay" id="prod_list">
    <div class="content">
       <h3 class="mc_title"> 
            <span class="mctit_1"><span class="mctit_2"><?=$page_title?></span></span>
            <?if($_SESSION['com_type']!=='景区' && $status!==2):?>
            <span class="mctit_1 mctit_3"><a href="prod_sale.html" class="mctit_2 mctit_4">转分销产品</a></span>
            <?endif;?>
        </h3> 
		
        <form class="search_form" id="search_form" action="<?=$_SERVER['PHP_SELF'];?>" method="get">
            <input type="hidden" name="act" id="act"/>
            <table class="search_tbl">
                <?php if($_SESSION['memberID']==1):?>
                    <link href="js/plugin/jq/jquery-ui.min.css" rel="stylesheet">
                    <tr>
                        <th>供应商：</th>
                        <td>
                            <select class="fenxiaoSelect controls" name="supplier" id="">
                                <option value="">请选择供应商</option>
                                <?foreach($DistorsNames as $key=> $cn):?>
                                <option value="<?=$key?>" <?if($_REQUEST['supplier']==$key)echo 'selected="selected"'?>><?=$cn?></option>
                                <?endforeach;?>
                            </select>
                            <input name="apply_did" type="hidden" value="<?=$_GET['apply_did']?>"/>
                            地d区：<span id="area"></span>
                            <input name="area" type="hidden" value="<?=$_GET['d_province'].'|'.$_GET['d_city']?>"/>
							<input type="checkbox" name="only" value="1">仅列出产品
                        </td>
						
                    </tr>
                    <script src="js/plugin/jq/jquery-ui-1.10.4.min.js"></script>
                    <script>
                        (function(){
                            $("input[name='s_app_name']").autocomplete({
                                source: function( request, response ) {
                                    $.getJSON( "call/jh_mem.php", {
                                        action: 'SearchProviders',
                                        dname: extractLast( request.term )
                                    }, response );
                                },
                                minLength: 2,
                                select: function( event, ui ) {
                                    $(this).next('input:hidden').val(ui.item.id);
                                }
                            });
                        })();
                    </script>
                <?php else:?>
                <tr>
                    <th>地区：</th>
                    <td>
                        <span id="area"></span>
                        <input name="area" type="hidden" value="<?=$_GET['d_province'].'|'.$_GET['d_city']?>"/>
                    </td>
					
                </tr>
                <?php endif;?>
                <script src="js/jquery.getareas.js" type="text/javascript"></script>
                <script>
                    function split( val ) {
                        return val.split( /,\s*/ );
                    }
                    function extractLast( term ) {
                        return split( term ).pop();
                    }
                    $(document).ready(function(){
                        if($("#area").length){
                            var area,pro_id, city_id,countr_id;
                            if($("input[name='area']").val()){
                                area = $("input[name='area']").val().split('|'),
                                        por_id = area[0],city_id = area[1],country_id = area[2];
                            }
                            var areaParam = {
                                    update:true,
                                    pro_id:por_id,
                                    city_id:city_id,
                                    county_id:country_id,
                                    depth:2
                            };
                            $("#area").getAreas(areaParam);
                        }
                        $("input[name='s_app_name']").on('keyup', function(){
                            if ($(this).val().length==0) {
                                $(this).next('input:hidden').val('');
                            }
                        })
                    });
                </script>
                <tr>
                    <th>产品名称：</th>
                    <td>
                        <input type="text" class="input-txt w300" title="请输入产品名称或产品ID或6位数产品编号" placeholder="请输入产品名称或产品ID或6位数产品编号" name="s_title" value="<?=$_GET['s_title']?>" maxlength="30"/>
                        <a href="javascript:" class="search_btn" onclick="$('form#search_form').submit()">搜　索</a>
                        <a href="javascript:" class="more">更多筛选条件 <i class="arrow">&nbsp;</i></a>
                    </td>
                </tr>
				
                <tr  class="more hidden">
                    <th>产品类型：</th>
                    <td>
                        <select name="p_type">
                            <option value="">不限</option>
                            <option value="A">景点</option>
                            <option value="B">线路</option>
                            <option value="C">酒店</option>
                            <option value="F">套票</option>
                        </select>
                        <span class="s_title" style="margin:0 10px 0 9px">
                            终端号：<input type="text" class="input-txt w60" value="<?=$_GET['terminal']?>" name="terminal"/>
                        </span>
						
                    </td>
					
						
					
                </tr>
				
            </table>
			<div class="up_file" ><input type="button" class="export exportbtn" value="导出" id="excel"></div>
        </form>
        <div class="boxs" id="boxContainer">
            <?php if(!$data['total']):?>
                <div class="box noresult">您还未发布任何产品，赶快去<a href="prod_type.html">发布</a>吧！</div>
                <?php return;?>
            <?php endif;?>
            <?php foreach($data['lands'] as $prod):?>
                <?php
                    $areaHtml = '';
                    if(!empty($prod['area'])) {
                        list($prov, $city) = explode('|', $prod['area']);
                        $areaHtml = '<span class="area">['.$areas[$prov].' '.$areas[$city].']</span>';
                    }
                ?>
            <div class="box" id="box_<?=$prod['id']?>">
				<?if($status==2 && array_key_exists('S:'.$prod['id'],$packageMsg)):?>
				<p style="color:red;margin:10px 10px 0;">
				<? echo $packageMsg['S:'.$prod['id']]['timer'],'  ',$packageMsg['S:'.$prod['id']]['message'];?>
				</p>
				<?endif;?>
                <?php if($status!=1):?>
                <div class="rm" data-sid="<?=$prod['id']?>">
                    <a class="set_ls" href="javascript:" data-state="3" title="删除该产品及所有票类">&nbsp;</a>
                </div>
                <?php endif;?>
                <div class="imgDiv">
                    <a><img class="small" src="<?=$prod['imgpath']?>" onerror="javascript:this.src='http://www.12301.cc/images/sorry_pic.png'"></a>
                    <div class="bigpic none"><img class="normal" src="<?=$prod['imgpath']?>" style="width: 0px; display: inline-block;"></div>
                </div>
                <div class="linfo">
                    <p class="list">
                        <?=$areaHtml?><?=!empty($prod['jtype'])?"<span>{$prod['jtype']}</span>":''?><span>终端号：<?=$prod['terminal']?></span>
                    </p>
                    <p class="title">
                        <a href="scenicDetail.html?lid=<?=$prod['id']?>" target="_blank"><?=$prod['title']?></a>
                        <span class="normal_font">(ID:<?=$prod['salerid']?>)</span>
                    </p>
                    <p class="dname">
                        供应商：<?=$memberNames[$prod['apply_did']]?>
                    </p>
                    <p class="address">地址：<?=$prod['address']?></p>
                </div>

                <div class="oprate">
                    <?php $c_t = count($data['tickets'][$prod['id']]);?>
                    <?php if($prod['sync_status']==2):?>
                        同步产品禁止操作
                    <?php else:?>
                    <p data-sid="<?=$prod['id']?>">
                        <?if($prod['status']==1):?>
                        <a class="set_ls lnk mmxj" href="javascript:" data-state="2" data-type="<?=$prod['p_type']?>">&nbsp;</a>
                        <? else :?>
                        <a class="set_ls lnk mmsj" href="javascript:" data-state="1" data-type="<?=$prod['p_type']?>">&nbsp;</a>
                        <?endif;?>
                        <a class="lnk mmxg" href="prod_edits.html?sid=<?=$prod['id']?>" target="_blank">&nbsp;</a>
                    </p>
                    <p >
                        <?if($prod['p_type']=='F'):?>
                        	<?if($c_t)://套票门票数量判断?>
							<!--<a class="lnk lnk_l mmtj" href="javascript:alert('套票只能有一张门票');" target="_blank">&nbsp;</a>-->
							<?else:?>
							<a class="lnk lnk_l mmtj" href="product_publish_tar.html?sid=<?=$prod['id']?>" target="_blank">&nbsp;</a>
							<?endif;//套票门票数量判断结束?>
						<?else:?>
						<a class="lnk lnk_l mmtj" href="product_publish.html?sid=<?=$prod['id']?>" target="_blank">&nbsp;</a>
						
						<?endif;?>
                    </p>
                    <p >
                        <a class="lnk lnk_l mmyz" href="terminal_chk.html?sid=<?=$prod['id']?>" target="_blank">&nbsp;</a>
                    </p>
                    <?php endif;?>
                </div>

                <div class="detail">
                    <p>
                        <span class="dollar"><i>¥</i>
                        <?if($_GET['z'])print_r($data['tickets'][$prod['id']]);?>
                        <strong class="minprice"><?=is_array($data['tickets'][$prod['id']]) ? min_by_key($data['tickets'][$prod['id']],'fprice') : 0;?></strong></span>起
                    </p>
                    <!--<p><a href="scenicDetail.html?lid=<?=$prod['id']?>" target="_blank">散客预定</a></p>-->
					<?if($_SESSION['sid']==1433 || $_SESSION['sid']==4971 || $_SESSION['sid']==7508):?>
					<p><a href="prod_edits_child_list.html?lid=<?=$prod['id']?>" target="_blank">导览信息</a></p>
					<?endif;?>
                    
                    <?php if($prod['sync_status']==2):?>
                    <p><a class="sync" data-action="cancel_sync_land" data-lid="<?=$prod['id']?>" href="javascript:;" >取消同步</a></p>
                    <?php endif;?>
                </div>
                <table class="ticket_list">
                    <thead>
                    <tr>
                        <th class="id">产品ID</th>
                        <th class="title">票名称</th>
                        <th class="price">供货价</th>
                        <th class="price">建议零售价</th>
                        <th class="price">门市价</th>
                        <th class="craettime">创建时间</th>
                        <th class="storage">库存</th>
                        <th class="sale">销量</th>
                        <th>销售范围</th>
                        <th>状态</th>
                        <th class="operate">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                        <?php if(!$c_t): ?>
                            <tr><td colspan="11">未添加票类或已下架</td></tr>
                        <?php else:?>
                            <?php foreach($data['tickets'][$prod['id']] as $key => $ticket):?>
                            <?php
                                $class = '';
                                if($c_t==($key+1)) {
                                    $class = 'last';
                                }
                                if($key>5) {
                                    $class .= ' hidden more';
                                }
                            ?>
                            <tr data-land="<?=$ticket['landid']?>" class="<?=$class?>" id="tr_<?=$ticket['pid']?>">
                                <td title="供应商aid|景区lid|门票tid" class="id" data-tid="<?=$ticket['id']?>"><?=$prod['apply_did']?>|<?=$prod['id']?>|<?=$ticket['id']?></td>
                                <?if($prod['p_type']=='F'):?>
								<td data-pid="<?=$ticket['pid']?>" class="title" title="<?=$ticket['title']?>"><a href="ticket_edit_tar.html?sid=<?=$prod['id']?>&prod_id=<?=$ticket['id']?>" target="_blank"><?=mb_substr($ticket['title'],0, 10,'utf-8')?></a></td>
								<?else:?>
								<td data-pid="<?=$ticket['pid']?>" class="title" title="<?=$ticket['title']?>"><a href="ticket_edit.html?sid=<?=$prod['id']?>&prod_id=<?=$ticket['id']?>" target="_blank"><?=mb_substr($ticket['title'],0, 10,'utf-8')?></a></td>
								<?endif;?>
                                <td class="price gprice"><strong><?=(is_numeric($ticket['fprice'])?'<i class="dollar">¥</i>':'').$ticket['fprice'];?></strong></td>
                                <td class="price lprice"><?=(is_numeric($ticket['uprice'])?'<i class="dollar">¥</i>':'').$ticket['uprice'];?></td>
                                <td class="price tprice"><i class="dollar">¥</i><?=$ticket['tprice']?></td>
                                <td class="create_time" title="<?=$ticket['verify_time']?>"><?=substr($ticket['verify_time'],0,10)?></td>
                                <td class="storage"><?=$ticket['storage']==-1? '不限' : $ticket['storage']; ?></td>
                                <td class="sale"><a href="javascript:;" class="wSales">查看</a></td>
                                <td class="p2l"><?=$P2L[$ticket['p_status']]?></td>
                                <td class="vst"><?=$ProdState[$ticket['apply_limit']]?></td>
                                <td class="operate">
                                    <a href="adjusting.html?pid=<?=$ticket['pid']?>" target="_blank">分销价格</a>
                                    <?php if($ticket['sync_status']!=2):?>
                                        <a href="storageConfig.html?pid=<?=$ticket['pid']?>" target="_blank">库存</a>
                                        <?php if($ticket['apply_limit']==2):?>
                                        <a href="javascript:;" class="set_state" data-state="1" data-pid="<?=$ticket['pid']?>">上架</a>
                                        <?php else:?>
                                        <a href="javascript:;" class="set_state" data-state="2" data-pid="<?=$ticket['pid']?>">下架</a>
                                        <?php endif;?>
                                        <a href="javascript:;" class="set_state" data-state="6" data-pid="<?=$ticket['pid']?>">删除</a>
                                    <?php endif;?>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                        <?php if($key>5):?>
                        <tr class="showMore"><td colspan="12"><a href="javascript:;" class="more">查看所有票类 <i class="arrow">&nbsp;</i></a></td></tr>
                        <?php endif;?>
                    <?php endif;?>
                    </tbody>
                </table>
            </div>
            <?php endforeach; ?>
            <?php page($data['total'],$currentPage,$pageSize);?>
        </div>
    </div>
</div>
<script>
$(function(){
    $("#excel").click(function(){
        $("#act").val("Export");
        $('form#search_form').submit();
    });
});

//    $(function(){
     //  $(".imgDiv img").each(function(){
      //     if(this.fileSize<=0)
     //         this.src="http://www.12301.cc/images/defaultThum.jpg";
     //  });
  //  });

</script>
<script type="text/javascript" src="js/easydialog.min.js"></script>
<script type="text/javascript" src="js/placeholder.min.js"></script>
<script type="text/javascript" src="js/prod_pub.js"></script>
<script type="text/javascript" src="js/prod_manage.js"></script>